<?php include "block_header.htm";?>

    <body>
        <div class="x-body">
            <form class="layui-form">
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>登录名
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="username" name="username" required="" lay-verify="required"
                               autocomplete="off" value="<?php echo $username ?>" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        至少5个字符
                    </div>
                </div>


                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        <span class="x-red">*</span>新密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="L_pass" name="password" required="" lay-verify="pass"
                               autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        6到16个字符
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        <span class="x-red">*</span>确认新密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="L_repass" name="repass" required="" lay-verify="repass"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item" style="position: absolute;left:45px;">
                    <label for="L_repass" class="layui-form-label">
                    </label>

                    <button  class="layui-btn" lay-filter="edit" lay-submit="" >
                        修改
                    </button>

                    <button  class="layui-btn" onclick="x_admin_close();return false;">
                        放弃
                    </button>

                </div>
            </form>

        </div>
        <script>

            layui.use(['form', 'layer'], function () {
                $ = layui.jquery;
                var form = layui.form
                        , layer = layui.layer;

                //自定义验证提交
                form.verify({
                    nikename: function (value) {
                        if (value.length < 5) {
                            return '用户名至少得5个字符啊';
                        }
                    }
                    , pass: [/(.+){6,12}$/, '密码必须6到12位']
                    , repass: function (value) {
                        if ($('#L_pass').val() !== $('#L_repass').val()) {
                            return '两次密码不一致';
                        }
                    }
                });

                //监听提交
                form.on('submit(edit)', function (data) {
                    //发异步，把数据提交给php
                    data.field.type = "user_edit";
                    x_admin_post("admin.php", data.field);     
                    return false;
                });

            });


        </script>
    </body>

</html>